#if SRP_URP
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace GameToolkit
{
    public class CullingCameraFeature : ScriptableRendererFeature
    {
        Dictionary<Camera, CullingCamera> mCullCams = new Dictionary<Camera, CullingCamera>();
        public override void OnCameraPreCull(ScriptableRenderer renderer, in CameraData cameraData)
        {
            CullingCamera culler;
            if (!mCullCams.TryGetValue(cameraData.camera, out culler)
#if UNITY_EDITOR
                || culler == null
#endif
                )
            {
                culler = cameraData.camera.GetComponent<CullingCamera>();
                mCullCams[cameraData.camera] = culler;
            }
            if (culler != null && culler.enabled)
                culler.OnPreCull();
        }

        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
        }

        public override void Create()
        {
        }
    }
}
#endif